class CreateResponse {
  final int code;
  final String msg;
  final List<CategoryData> data;

  CreateResponse({
    required this.code,
    required this.msg,
    required this.data,
  });

  factory CreateResponse.fromJson(Map<String, dynamic> json) {
    return CreateResponse(
      code: json['code'],
      msg: json['msg'],
      data: (json['data'] as List<dynamic>).map((item)=>CategoryData.fromJson(item as Map<String, dynamic>)).toList()
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'code': code,
      'msg': msg,
      'data':  data.map((category) => category.toJson()).toList(),
    };
  }
}

class CategoryData {
  String name;
  int id;
  List<AppItem> list;

  CategoryData({
    required this.name,
    required this.id,
    required this.list,
  });

  factory CategoryData.fromJson(Map<String, dynamic> json) {
    return CategoryData(
      name: json['name'],
      id: json['id'],
      list: (json['list'] as List<dynamic>).map((item)=>AppItem.fromJson(item as Map<String, dynamic>)).toList(),
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'name': name,
      'id': id,
      'list': list,
    };
  }

  static init() {
    return CategoryData(name: "", id: 0, list: [AppItem.init()]);
  }
}

class AppItem {
  String name;
  String memo;
  int id;

  AppItem({required this.name,required this.memo,required this.id});

  factory AppItem.fromJson(Map<String, dynamic> json) {
    return AppItem(
      name: json['name']??"",
      memo: json['memo']??"",
      id: json['id']??0,
    );
  }
  Map<String, dynamic> toJson() {
    return {
      'name': name,
      'memo': memo,
      'id': id,
    };
  }

  static init() {
    return AppItem(name: "", memo: "", id: 0);
  }
}